import { requestClient } from '#/api/request';

export namespace DemoApi {
  export interface PageFetchParams {
    [key: string]: any;
    page: number;
    pageSize: number;
    search?: string;
  }

  export interface CreateParams {
    name: string;
    sex: string;
    age: number;
    level: string;
  }

  export interface UpdateParams extends CreateParams {
    id: string;
  }
}

/**
 * 获取列表
 */
export async function getDemoApi(params: DemoApi.PageFetchParams) {
  return requestClient.get('/demo/list', { params });
}

/**
 * 创建
 */
export async function saveDemoApi(data: Record<string, any>) {
  return requestClient.post<DemoApi.CreateParams>('/demo/save', data);
}

/**
 * 删除
 */
export async function deleteDemoApi(id: number | string) {
  return requestClient.delete(`/demo/delete?id=${id}`);
}
